<!DOCTYPE html>
<html>
  <head><meta name="generator" content="Hexo 3.8.0">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="火骑小龙龙づ博客 vue mint-ui js html css 前端">
  <meta name="keyword" content="hexo-theme, vuejs">
  
    <link rel="shortcut icon" href="/css/images/logo.png">
  
  <title>
    
      OAuth 认证 | 火骑小龙龙づ博客
    
  </title>
  <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="//cdn.bootcss.com/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="//cdn.bootcss.com/highlight.js/9.12.0/styles/tomorrow.min.css" rel="stylesheet">
  <link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/plugins/gitment.css">
  <script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script src="//cdn.bootcss.com/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="//cdn.bootcss.com/nprogress/0.2.0/nprogress.min.js"></script>
  <script src="/js/qrious.js"></script>
<script src="/js/gitment.js"></script>
  
  
    <!-- MathJax support START -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <!-- MathJax support END -->
  


</head>
<div class="wechat-share">
  <img src="/css/images/logo.png">
</div>

  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>火骑小龙龙づ博客</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">Home</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags" class="item-link">Tags</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/categories" class="item-link">Categories</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives" class="item-link">Archives</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/project" class="item-link">Project</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about" class="item-link">About</a>
          
        </li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">Home</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags" class="menu-link">Tags</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/categories" class="menu-link">Categories</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives" class="menu-link">Archives</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/project" class="menu-link">Project</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about" class="menu-link">About</a>
            
          </li>
        
      </ul>
    </div>
  </div>
</header>


    <div id="article-banner">
  <h2>OAuth 认证</h2>
  <p class="post-date">2019-09-25</p>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><p>OAuth 认证 集合</p>
<a id="more"></a>
<blockquote>
<p>GitHub OAuth </p>
</blockquote>
<ul>
<li>认证流程 <a href="https://blog.csdn.net/kobe24lmlps/article/details/80838329" target="_blank" rel="noopener">链接</a> — <a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/" target="_blank" rel="noopener">文档</a><figure class="highlight jsx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* </span></span><br><span class="line"><span class="comment">    1. 授权 </span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    https://github.com/login/oauth/authorize?client_id=123123&amp;scope=user,public_repo</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    重定向到自己的网站地址  http://localhost:3000?code=12312312  (code 是一次性的，请求一次就作废了)</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    https://github.com/login/oauth/access_token?client_id=5ada8044d262eeafa684&amp;client_secret=ad599338d8a0dc525ed1be3f994cc8d2c9978153&amp;code=12312312</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    返回 token</span></span><br><span class="line"><span class="comment">    access_token=123123123&amp;scope=public_repo%2Cuser&amp;token_type=bearer</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    2. 获取用户信息</span></span><br><span class="line"><span class="comment">    https://api.github.com/user  需要携带 token(access_token) </span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    返回 </span></span><br><span class="line"><span class="comment">    &#123;</span></span><br><span class="line"><span class="comment">        "login": "",</span></span><br><span class="line"><span class="comment">        "id": ,</span></span><br><span class="line"><span class="comment">        "node_id": "",</span></span><br><span class="line"><span class="comment">        "avatar_url": "",</span></span><br><span class="line"><span class="comment">        "gravatar_id": "",</span></span><br><span class="line"><span class="comment">        "url": "",</span></span><br><span class="line"><span class="comment">        "html_url": "",</span></span><br><span class="line"><span class="comment">        "followers_url": "",</span></span><br><span class="line"><span class="comment">        "following_url": "",</span></span><br><span class="line"><span class="comment">        "gists_url": "",</span></span><br><span class="line"><span class="comment">        "starred_url": "",</span></span><br><span class="line"><span class="comment">        "subscriptions_url": "",</span></span><br><span class="line"><span class="comment">        "organizations_url": "",</span></span><br><span class="line"><span class="comment">        "repos_url": "",</span></span><br><span class="line"><span class="comment">        "events_url": "",</span></span><br><span class="line"><span class="comment">        "received_events_url": "",</span></span><br><span class="line"><span class="comment">        "type": "User",</span></span><br><span class="line"><span class="comment">        "site_admin": false,</span></span><br><span class="line"><span class="comment">        "name": "Amumu",</span></span><br><span class="line"><span class="comment">        "company": null,</span></span><br><span class="line"><span class="comment">        "blog": "",</span></span><br><span class="line"><span class="comment">        "location": null,</span></span><br><span class="line"><span class="comment">        "email": "",</span></span><br><span class="line"><span class="comment">        "hireable": null,</span></span><br><span class="line"><span class="comment">        "bio": "時長問自己，你的信仰是什麼？",</span></span><br><span class="line"><span class="comment">        "public_repos": 19,</span></span><br><span class="line"><span class="comment">        "public_gists": 0,</span></span><br><span class="line"><span class="comment">        "followers": 0,</span></span><br><span class="line"><span class="comment">        "following": 8,</span></span><br><span class="line"><span class="comment">        "created_at": "2017-07-01T05:53:47Z",</span></span><br><span class="line"><span class="comment">        "updated_at": "2019-09-25T03:39:55Z",</span></span><br><span class="line"><span class="comment">        "private_gists": 0,</span></span><br><span class="line"><span class="comment">        "total_private_repos": 0,</span></span><br><span class="line"><span class="comment">        "owned_private_repos": 0,</span></span><br><span class="line"><span class="comment">        "disk_usage": 14464,</span></span><br><span class="line"><span class="comment">        "collaborators": 0,</span></span><br><span class="line"><span class="comment">        "two_factor_authentication": false,</span></span><br><span class="line"><span class="comment">        "plan": &#123;</span></span><br><span class="line"><span class="comment">            "name": "free",</span></span><br><span class="line"><span class="comment">            "space": 976562499,</span></span><br><span class="line"><span class="comment">            "collaborators": 0,</span></span><br><span class="line"><span class="comment">            "private_repos": 10000</span></span><br><span class="line"><span class="comment">        &#125;</span></span><br><span class="line"><span class="comment">    &#125;</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure></li>
</ul>
</section>
    <!-- Tags START -->
    
      <div class="tags">
        <span>Tags:</span>
        
  <a href="/tags#OAuth">
    <span class="tag-code">OAuth</span>
  </a>

      </div>
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/2019/09/24/biancheng/Element/ElementUI-Vue踩坑集合/">
        <span class="nav-arrow">← </span>
        
          ElementUI+Vue踩坑集合
        
      </a>
    
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
      <div class="qrcode">
        <canvas id="share-qrcode"></canvas>
        <p class="notice">扫描二维码，分享此文章</p>
      </div>
    
    <!-- 二维码 END -->
    
      <!-- No Comment -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'http://taoaiyi1108.github.io/2019/09/25/biancheng/OAuth/OAuth-认证/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

     // error image
    $(".markdown-content img").on('error', function() {
      $(this).attr('src', 'http://file.muyutech.com/error-img.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function() {
      var src = $(this).attr('src')
      if (src !== 'http://file.muyutech.com/error-img.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()
        
        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="'+ src +'" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function() {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })

    // qrcode
    var qr = new QRious({
      element: document.getElementById('share-qrcode'),
      value: document.location.href
    });

    // gitment
    var gitmentConfig = "taoaiyi1108";
    if (gitmentConfig !== 'undefined') {
      var gitment = new Gitment({
        id: "OAuth 认证",
        owner: "taoaiyi1108",
        repo: "taoaiyi1108.github.io",
        oauth: {
          client_id: "0f87e490e00ee3fd87ef",
          client_secret: "4a9d2b148e7971c2201ad12131ce8bf8159ccd2e"
        },
        theme: {
          render(state, instance) {
            const container = document.createElement('div')
            container.lang = "en-US"
            container.className = 'gitment-container gitment-root-container'
            container.appendChild(instance.renderHeader(state, instance))
            container.appendChild(instance.renderEditor(state, instance))
            container.appendChild(instance.renderComments(state, instance))
            container.appendChild(instance.renderFooter(state, instance))
            return container;
          }
        }
      })
      gitment.render(document.getElementById('comments'))
    }
  })();
</script>

<script>
  var disqus_shortname = '';
  
  var disqus_url = 'http://taoaiyi1108.github.io/2019/09/25/biancheng/OAuth/OAuth-认证/';
  
  (function(){
    var dsq = document.createElement('script');
    dsq.type = 'text/javascript';
    dsq.async = true;
    dsq.src = '//go.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
</script>

    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
  <p class="copyright">
    &copy; 2019 火骑小龙龙 | Proudly powered by <a href="https://hexo.io" target="_blank">Hexo</a>
    <br>
    感谢大神 <a href="https://github.com/yanm1ng" target="_blank">yanm1ng</a> 对本博客的技术支持
  </p>
</footer>

<script>
  function async(u, c) {
    var d = document, t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async("//cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js", function(){
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async("//cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js", function(){
    $('figure pre').each(function(i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>
<!-- Baidu Tongji -->

<script src="/js/script.js"></script>
  </body>
</html>